package com.bw.jetpacktest.life;

import android.util.Log;

import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;

/**
 * lifecycle实现步骤:1.实现LifecycleObserver(lifecycle观察者)
 * 2.在LifePresenter方法中添加对应lifecycle注解；
 * 3.根据lifecycle下得Event事件下得枚举值关联activity生命周期
 * 4.activity中注册lifecycle观察者
 * 5.activity中销毁方法接触lifecycle观察者注册
 * */
public class LifePresenter implements LifecycleObserver {
    //初始化方法
    @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
    public void create(){
        Log.e("ZXY","LifePresenter->create()");
    }
    //Presenter关联得activity销毁时，释放rxjava观察者订阅
    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    public void destroy(){
        Log.e("ZXY","LifePresenter->destroy()");
    }
}
